<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/wipInventoryReport.do?action=scrapLotsReport"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); /*try {*/ %>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
</HEAD>
<script language="javascript">

    var dateElement = "";
    function openCalendar(dateValue)
    {
        dateElement = dateValue;
        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }

    function assignDate(passedValue)
    {
        dateElement.value=passedValue;
        window.focus();
    }

    function validateFromAndToDates()
    {
        formdoc = document.wipInventoryReportForm;
        errMsg = '';

        var pa	= document.getElementById("errors")

        if(chkDate(formdoc.fromDate.value,'From-Date','N') == false)
        {
            pa.innerHTML = errMsg;
            formdoc.fromDate.focus();
            return false;
        }

        if(chkDate(formdoc.toDate.value,'To-Date','N') == false)
        {
            pa.innerHTML = errMsg;
            formdoc.toDate.focus();
            return false;
        }

        if(formdoc.fromDate.value!='' && formdoc.toDate.value!='')
        {
            if (!validateDateOut(formatDateAsMMDDYYYY(formdoc.fromDate.value),formatDateAsMMDDYYYY(formdoc.toDate.value)))
            {
                pa.innerHTML = "To Date cannot be less than From Date";
                formdoc.toDate.focus();
                return false;
            }
        }
        return true;
    }

    function loadProductsbyType()
    {
	    document.wipInventoryReportForm.action="<%=chipTracContext%>/wipInventoryReport.do?action=scrapLotsReport";
	    document.wipInventoryReportForm.submit();
    }

    function submitReport(fileType)
    {
        var d = new Date();
        var day = d.getDate();
        var month = d.getMonth()+1;
        var year = d.getFullYear();
        var hour = d.getHours();
        var min = d.getMinutes();
        var sec = d.getSeconds();
        var pa	= document.getElementById("errors")
        var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;
        var success;
        var formdoc = document.wipInventoryReportForm

        success = true;
        success = validateFromAndToDates();
        if( success == false )
        {
           return ;
        }

        var partNumberObj = formdoc.productId;
        var processstepId = "";
        var count = 0;
        for( var i = 0; i < partNumberObj.length; i++ )
        {
            if( partNumberObj.options[i].selected )
            {
                count++;
                if ( processstepId != '' )
                {
                    processstepId = processstepId + "," + partNumberObj.options[i].value;
                }
                else
                {
                    processstepId = partNumberObj.options[i].value;
                    if( partNumberObj.options[i].value == '0' )
                    {
                        break;
                    }
                }
            }
        }
        if ( processstepId == '')
        {
            processstepId = "0";
        }
        if( count > 10)
        {
            pa.innerHTML = "<li>Please select upto 10 Products only";
            return;
        }
        else
        {
            formdoc.prompt1.value = processstepId;
        }

        if ( formdoc.psType.value == '' )
        {
            formdoc.prompt0.value = '0';
        }
        else
        {
            formdoc.prompt0.value = formdoc.psType.value;
        }

        if ( formdoc.vendorId.value == '' )
        {
            formdoc.prompt2.value = '0';
        }
        else
        {
            formdoc.prompt2.value = formdoc.vendorId.value;
        }

        if ( formdoc.lotCategory.value == '' )
        {
            formdoc.prompt3.value = '0';
        }
        else
        {
            formdoc.prompt3.value = formdoc.lotCategory.value;
        }

        if ( formdoc.fromDate.value == '' )
        {
            formdoc.prompt4.value = '0';
        }
        else
        {
            formdoc.prompt4.value = formdoc.fromDate.value;
        }

        if ( formdoc.toDate.value == '' )
        {
            formdoc.prompt5.value = '0';
        }
        else
        {
            formdoc.prompt5.value = formdoc.toDate.value;
        }

        formdoc.prompt6.value = "Crystal";
        formdoc.prompt7.value = formdoc.scrapType.value;
        formdoc.prompt8.value = defaultPrompt;
        formdoc.prompt9.value = '';
        formdoc.prompt10.value = '';

        if ( fileType == 2 )
        {
            var prompt0 = formdoc.prompt0.value;
            var prompt1 = formdoc.prompt1.value;
            var prompt2 = formdoc.prompt2.value;
            var prompt3 = formdoc.prompt3.value;
            var prompt4 = formdoc.prompt4.value;
            var prompt5 = formdoc.prompt5.value;
            var prompt6 = "xlreport"; // for report type prompt
            var prompt7 = formdoc.prompt7.value;
            var prompt8 = formdoc.prompt8.value; // for default prompt

            //var newWindow;
            //var url = '<%=chipTracContext%>/dataDumpReportAction.do?action=generateScrapLotsXlsReport&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 ;
            //newWindow = window.open ( url, 'ScrapLotsReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
            formdoc.action='<%=chipTracContext%>/dataDumpReportAction.do?action=generateScrapLotsXlsReport&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6 + '&prompt7=' + prompt7 + '&prompt8=' + prompt8 ;
            formdoc.submit();
            return true;
            }
        else
        {
            formdoc.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Operations/Scrap_Lots_Report.rpt";
            formdoc.submit();
            return true;
        }
    }

</script>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" >
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
    <!-- Side Navigation start -->
    <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
    <!-- end of the side navigations -->
    </TD>
    <TD bgcolor="#ffffff">
        <IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8"></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="2"></TD>
        <TD valign="top" width="100%">
        <IMG height="1" src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" border="0">
        <BR>
        <html:form name="wipInventoryReportForm" type="com.scalar.chiptrack.operations.reports.forms.WipInventoryReportForm" action="/wipInventoryReport">
        <TABLE border="0" width="100%" align="center">
            <TR><TD colspan="6" class="NArialW" align="center">Scrap Lots Report</TD></TR>
            <TR>
                <TD colspan="6">
                    <input type="hidden" name="prompt0">
                    <input type="hidden" name="prompt1">
                    <input type="hidden" name="prompt2">
                    <input type="hidden" name="prompt3">
                    <input type="hidden" name="prompt4">
                    <input type="hidden" name="prompt5">
                    <input type="hidden" name="prompt6">
                    <input type="hidden" name="prompt7">
                    <input type="hidden" name="prompt8">
                    <input type="hidden" name="prompt9">
                    <input type="hidden" name="prompt10">
                </TD>
            </TR>
            <TR><TD colspan="6">&nbsp;</TD></TR>
            <TR><TD width="12%" >&nbsp;</TD><TD colspan="6" class='NArialL' align="left"><strong><FONT id="errors" styleClass="NArialL" color='FF0000'>&nbsp;</FONT></strong></TD></TR>
            <TR>
                <TD>&nbsp;</TD>
                <TD colspan="6" align="left">
                  <chiptrack:info styleClass="NArialL" />
                  <chiptrack:errors styleClass="NArialL" />
                  <chiptrack:messages type="info" styleClass="NArialL" />&nbsp;
                </TD>
            </TR>
            <TR>
                <TD colspan="6">
                    <TABLE align="center" border="0" width="100%" cellspacing="3" cellpadding="2">
                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top'>Process Types</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="psType" name="wipInventoryReportForm" styleClass="txfield" style="width:140px" onchange = 'loadProductsbyType()' >
                                    <html:option value="0">All Process Steps</html:option>
                                    <html:options collection="processList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "center">Products &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="productId" name="wipInventoryReportForm" styleClass="txfield" style="width:140px" multiple="true" size="5">
                                    <html:option value="0">All Products</html:option>
                                    <html:options collection="mktgPartNumberList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>

                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>

                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' >Vendor</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="vendorId" name="wipInventoryReportForm" styleClass="txfield" style="width:120px" >
                                    <html:options collection="vendorList" property="label" labelProperty="label"/>
                                </html:select>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "center">Lot Category</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="lotCategory" name="wipInventoryReportForm" styleClass="txfield" style="width:120px" >
                                    <html:options collection="categoryList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>

                         <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>

                        <TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' >Scrap Type</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="scrapType" name="wipInventoryReportForm" styleClass="txfield" style="width:120px" >
                                    <html:options collection="scrapTypesList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "center"> &nbsp;</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                               &nbsp;
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>

                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" nowrap="true">From Date</TD>
                            <TD width="20%" class="NArialL">
                                <html:text property="fromDate" name="wipInventoryReportForm" styleClass="txfield" size="12"/>
                                <a href="javascript:openCalendar(document.wipInventoryReportForm.fromDate)"onmouseover="window.status='Click to Select From Date';return true"onmouseout="window.status='';return true"title="Click here to Select From Date">
                                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18>
                                </a>
                            </TD>
                            <TD width="15%" class="NArialL" nowrap="true" align = "center">To Date &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
                            <TD width="20%" class="NArialL">
                                <html:text property="toDate" name="wipInventoryReportForm" styleClass="txfield" size="12"/>
                                <a href="javascript:openCalendar(document.wipInventoryReportForm.toDate)"onmouseover="window.status='Click to Select To Date';return true"onmouseout="window.status='';return true"title="Click here to Select To Date">
                                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18>
                                </a>
                            </TD>
                            <TD width="15%">&nbsp;</TD>
                        </TR>

                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>
                        <%--<TR>
                            <TD width="10%" >&nbsp;</TD>
                            <TD width="15%" >&nbsp;</TD>
                            <TD width="20%" >&nbsp;</TD>
                            <TD width="15%" >&nbsp;</TD>
                            <td width="20%" class="NArialL" >
                                <a class="NArialL" href="javascript:submitReport(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
                            </td>
                            <TD width="15%">&nbsp;</TD>
                        </TR>
--%>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></TD></TR>
                        <TR>
                            <TD colspan="6" align=center>
                                <a href="javascript:submitReport(2);"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Report';return true" onmouseout="window.status='';return true" title='Click to Generate Report'></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="javascript:document.wipInventoryReportForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset search';return true" onmouseout="window.status='';return true" title="Click here to reset search"></a>
                            </TD>
                        </TR>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                    </TABLE>
                </TD>
            </TR>
        </TABLE>
        </html:form>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
<%--<% } catch(Exception e){e.printStackTrace();} %>--%>
